package cn.fzkj.gulimall.product.web;

import cn.fzkj.gulimall.product.entity.CategoryEntity;
import cn.fzkj.gulimall.product.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * @DESCRIPTION 首页
 * @Author yaya
 * @DATE 2022/5/15
 */
@Controller
public class IndexController {

    @Autowired
    private CategoryService categoryService;

    @RequestMapping({"/", "/index.html"})
    public String index(Model mv){
        List<CategoryEntity> data = categoryService.getCategories();

        mv.addAttribute("categories", data);

        return "index";
    }
}
